#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 10;
const int maxs = 1<<maxn;

int dp[maxs+5], w[maxn+1][maxn+1];
int N;


int cnt(int s){
    int c = 0;
    while(s&(-s)) s^=s&(-s), ++c;
    return c;
}

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    while (cin >> N && N){
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                cin >> w[i][j];
            }
        }
        memset(dp, 0, sizeof dp);
        vector<int> S[N+1];
        for (int i = 0; i < 1<<N; ++i) {
            S[cnt(i)].push_back(i);
        }
        for (int C = 1; C <= N-1; ++C) {
            for(int s:S[C]){
                for (int i = 0; i < N; ++i) if((1<<i)&s){
                    for (int j = 0; j < N; ++j) if(!((1<<j)&s)){
                        int ss = s | (1<<j);
                        dp[ss] = max(dp[ss], dp[s] + w[i][j]);
                    }
                }
            }
        }
        cout << dp[(1<<N)-1] << "\n";
    }
    return 0;
}